package bma.common.langutil.xdom;

import java.util.Iterator;

public abstract class Xdom {

	public abstract XdomType type();
	
	public String xtype() {return null;};

	public boolean isValueNode() {
		XdomType t = type();
		switch (t) {
		case BOOLEAN:
		case STRING:
		case NULL:
		case NUMBER:
			return true;
		}
		return false;
	}

	public boolean isContainerNode() {
		XdomType t = type();
		switch (t) {
		case ARRAY:
		case MAP:
			return true;
		}
		return false;
	}

	public boolean isArray() {
		return type() == XdomType.ARRAY;
	}

	public boolean isMap() {
		return type() == XdomType.MAP;
	}

	public boolean isNumber() {
		return type() == XdomType.NUMBER;
	}

	public boolean isString() {
		return type() == XdomType.STRING;
	}

	public boolean isBoolean() {
		return type() == XdomType.BOOLEAN;
	}

	public boolean isNull() {
		return type() == XdomType.NULL;
	}

	public String getStringValue() {
		return null;
	}

	public boolean getBooleanValue() {
		return false;
	}

	public Number getNumberValue() {
		return null;
	}

	public int getIntValue() {
		Number v = getNumberValue();
		return v == null ? 0 : v.intValue();
	}

	public long getLongValue() {
		Number v = getNumberValue();
		return v == null ? 0 : v.longValue();
	}

	public double getDoubleValue() {
		Number v = getNumberValue();
		return v == null ? 0 : v.doubleValue();
	}

	public Xdom get(int index) {
		return null;
	}

	public Xdom get(String fieldName) {
		return null;
	}

	public boolean has(String fieldName) {
		return false;
	}

	public boolean has(int index) {
		return index<size();
	}

	public int size() {
		return 0;
	}

	public Iterator<Xdom> arrayIterator() {
		return null;
	}

	public Iterator<String> mapNames() {
		return null;
	}

}
